<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Version: $Revision: 2 $ -->
<project name="miggy" default="all" basedir=".">
  <property file="build.properties"/>
	<property name="module.name" value="miggy"/>
	<property name="build.dir" location="build"/>
	<property name="build.prod.dir" location="${build.dir}/prod"/>
	<property name="build.test.dir" location="${build.dir}/test"/>
	<property name="src.dir" location="src"/>
	<property name="test.dir" location="test"/>
	<property name="vendor.lib.dir" location="lib"/>

	<!-- Manifest options -->
	<property name="manifest.package" value="miggy"/>
	<property name="manifest.title" value="miggy Amiga Emulator"/>
	<property name="manifest.vendor" value="The Miggy Project"/>

	<!-- Compiler options -->
	<property name="compiler.debug" value="off"/>
	<property name="compiler.no.warnings" value="off"/>
	<property name="compiler.args" value=""/>
	<property name="compiler.max.memory" value="128m"/>

	<!-- JDK definitions -->
	<property name="jdk.bin.dir" value="${jdk.home.dir}/bin"/>
	<property name="project.jdk.home" value="${jdk.home.dir}"/>
	<property name="project.jdk.bin" value="${jdk.bin.dir}"/>
	<property name="project.jdk.classpath" value="jdk.classpath"/>

	<path id="jdk.classpath">
		<fileset dir="${jdk.home.dir}">
			<include name="jre/lib/charsets.jar"/>
			<include name="jre/lib/jce.jar"/>
			<include name="jre/lib/jsse.jar"/>
			<include name="jre/lib/plugin.jar"/>
			<include name="jre/lib/rt.jar"/>
			<include name="jre/lib/sunrsasign.jar"/>
			<include name="jre/lib/ext/dnsns.jar"/>
			<include name="jre/lib/ext/ldapsec.jar"/>
			<include name="jre/lib/ext/localedata.jar"/>
			<include name="jre/lib/ext/sunjce_provider.jar"/>
		</fileset>
	</path>

	<path id="project.classpath">
		<pathelement location="${build.prod.dir}" />
		<pathelement location="${build.test.dir}" />
		<fileset dir="${vendor.lib.dir}">
			<include name="*.jar"/>
		</fileset>
	</path>

	<patternset id="compiler.resources">
		<include name="**/?*.properties"/>
		<include name="**/?*.xml"/>
		<include name="**/?*.gif"/>
		<include name="**/?*.png"/>
		<include name="**/?*.jpeg"/>
		<include name="**/?*.jpg"/>
		<include name="**/?*.html"/>
		<include name="**/?*.dtd"/>
		<include name="**/?*.tld"/>
		<include name="**/?*.wsdd"/>
	</patternset>

	<target name="compile" depends="compile.prod,compile.tests" description="compile prod and test code"/>

	<target name="compile.prod" description="Compile production code">
		<mkdir dir="${build.prod.dir}"/>
		<javac srcdir="${src.dir}" destdir="${build.prod.dir}" nowarn="${compiler.no.warnings}"
				debug="${compiler.debug}" memoryMaximumSize="${compiler.max.memory}" fork="true"
				executable="${project.jdk.bin}/javac" >
			<classpath refid="project.classpath"/>
			<classpath refid="${project.jdk.classpath}"/>
		</javac>

		<copy todir="${build.prod.dir}">
		  <fileset dir="${src.dir}">
			<patternset refid="compiler.resources"/>
			<type type="file"/>
		  </fileset>
		</copy>
	</target>

	<target name="compile.tests" depends="compile.prod" description="Compile test code">
		<mkdir dir="${build.test.dir}"/>
		<javac srcdir="${test.dir}" destdir="${build.test.dir}" nowarn="${compiler.no.warnings}"
				debug="${compiler.debug}" memoryMaximumSize="${compiler.max.memory}" fork="true"
				executable="${project.jdk.bin}/javac" >
			<classpath refid="project.classpath"/>
			<classpath refid="${project.jdk.classpath}"/>
		</javac>
		<copy todir="${build.test.dir}">
			<fileset dir="${test.dir}">
				<patternset refid="compiler.resources"/>
				<type type="file"/>
			</fileset>
		</copy>
	</target>

	<target name="test" depends="compile.tests" description="Run unit tests">
		<junit haltonfailure="true">
			<classpath refid="project.classpath"/>
			<formatter type="brief" usefile="false"/>
			<batchtest>
				<fileset dir="${build.test.dir}" includes="**/*Test.class"/>
			</batchtest>
		</junit>
	</target>

	<target name="package" depends="test" description="Build jar file">
		<tstamp>
			<format property="build.time" pattern="dd MMMM yyyy HH:mm" timezone="GMT"/>
		</tstamp>
		<manifest file="${build.dir}/MANIFEST.MF">
			<attribute name="Built-By" value="${user.name}"/>
			<section name="${manifest.package}">
				<attribute name="Specification-Title" value="${manifest.title}"/>
				<attribute name="Specification-Version" value="${build.version}"/>
				<attribute name="Specification-Vendor" value="${manifest.vendor}"/>
				<attribute name="Implemention-Title" value="${manifest.package}"/>
				<attribute name="Implemention-Version" value="${build.version} ${build.time}"/>
				<attribute name="Implemention-Vendor" value="${manifest.vendor}"/>
			</section>
		</manifest>
		<jar destfile="${build.dir}/${module.name}.jar" manifest="${build.dir}/MANIFEST.MF" basedir="${build.prod.dir}"/>
	</target>

	<target name="init" description="Build initialization">
		<!-- Perform any build initialization in this target -->
	</target>

	<target name="clean" description="cleanup">
		<delete dir="${build.dir}"/>
	</target>

	<target name="all" depends="clean, init, compile, test, package" description="build all"/>

</project>